use "C:\Documents and Settings\axz051000\My Documents\guale2009\stan\cps\restatonline\october1997cpsfinal.dta" 

joinby gtmsa using december1998cpsfinal.dta, unmatched(both)
tab _merge
drop _merge
joinby gtmsa using august2000cpsfinal.dta, unmatched(both)
tab _merge
drop _merge

joinby gtmsa using september2001cpsfinal.dta, unmatched(both)
tab _merge
drop _merge

joinby gtmsa using october2003cpsfinal.dta, unmatched(both)
tab _merge
drop _merge
joinby gtmsa using august2000cpsfinal.dta, unmatched(both)
tab _merge
drop _merge
joinby gtmsa using oct1995cpsfinal.dta, unmatched(both)
tab _merge
drop _merge
*population is total hesiu1 weighted by population*
joinby gtmsa using populationcps1997_2003.dta, unmatched(both)
tab _merge
drop population1998
drop if gtmsa==4940
*Merced CA, is not in dataferret when making a table. It has 83 observations and only two people in the oldest cohort*

*internet in USA in 1997*
egen population1997=sum(popu1997)
gen internetuse97w=internetusehh1997*popu1997
egen internetuse97ww=sum(internetuse97w)
gen interntuseusa1997=internetuse97ww/population1997

*in 1997 the question hesiu3 does not exist, internet for the household is 1 if anybody in the hh uses the internet at home*

egen population1998=sum(popu1998)
gen internetuse98w=internetuse1998*popu1998
egen internetuse98ww=sum(internetuse98w)
gen interntuseusa1998=internetuse98ww/population1998

egen population2000=sum(popu2000)
gen internetuse00w=internetuse2000*popu2000
egen internetuse00ww=sum(internetuse00w)
gen interntuseusa2000=internetuse00ww/population2000

egen population2001=sum(popu2001)
gen internetuse01w=internetuse2001*popu2001
egen internetuse01ww=sum(internetuse01w)
gen interntuseusa2001=internetuse01ww/population2001

egen population2003=sum(popu2003)
gen internetuse03w=internetuse2003*popu2003
egen internetuse03ww=sum(internetuse03w)
gen interntuseusa2003=internetuse03ww/population2003

drop _merge
joinby gtmsa using dmamsasep2008.dta, unmatched(both)
tab _merge

egen popudma1997=sum(popu1997), by(dmacode)
egen popudma1998=sum(popu1998), by(dmacode)
egen popudma2000=sum(popu2000), by(dmacode)
egen popudma2001=sum(popu2001), by(dmacode)
egen popudma2003=sum(popu2003), by(dmacode)


gen internetw97=internetusehh1997*popu1997
egen internetwdma97=sum(internetw97), by(dmacode)
rename internetuse1997 nada1997
gen internetuse1997=internetwdma97/popudma1997

gen internetw98=internetuse1998*popu1998
egen internetwdma98=sum(internetw98), by(dmacode)
rename internetuse1998 nada1998
gen internetuse1998=internetwdma98/popudma1998

gen internetw00=internetuse2000*popu2000
egen internetwdma00=sum(internetw00), by(dmacode)
rename internetuse2000 nada2000
gen internetuse2000=internetwdma00/popudma2000

gen internetw01=internetuse2001*popu2001
egen internetwdma01=sum(internetw01), by(dmacode)
rename internetuse2001 nada2001
gen internetuse2001=internetwdma01/popudma2001

gen internetw03=internetuse2003*popu2003
egen internetwdma03=sum(internetw03), by(dmacode)
rename internetuse2003 nada2003
gen internetuse2003=internetwdma03/popudma2003

gen incomew95=income1995*popu1997
egen incomewdma95=sum(incomew95), by(dmacode)
rename income1995 inada1995
gen income1995=incomewdma95/popudma1997

gen incomew97=income1997*popu1997
egen incomewdma97=sum(incomew97), by(dmacode)
rename income1997 inada1997
gen income1997=incomewdma97/popudma1997

gen incomew98=income1998*popu1998
egen incomewdma98=sum(incomew98), by(dmacode)
rename income1998 inada1998
gen income1998=incomewdma98/popudma1998

gen incomew00=income2000*popu2000
egen incomewdma00=sum(incomew00), by(dmacode)
rename income2000 inada2000
gen income2000=incomewdma00/popudma2000

gen incomew01=income2001*popu2001
egen incomewdma01=sum(incomew01), by(dmacode)
rename income2001 inada2001
gen income2001=incomewdma01/popudma2001

gen incomew03=income2003*popu2003
egen incomewdma03=sum(incomew03), by(dmacode)
rename income2003 inada2003
gen income2003=incomewdma03/popudma2003





gen educw95=educ1995*popu1997
egen educwdma95=sum(educw95), by(dmacode)
rename educ1995 enada1995
gen educ1995=educwdma95/popudma1997

gen educw97=educ1997*popu1997
egen educwdma97=sum(educw97), by(dmacode)
rename educ1997 enada1997
gen educ1997=educwdma97/popudma1997

gen educw98=educ1998*popu1998
egen educwdma98=sum(educw98), by(dmacode)
rename educ1998 enada1998
gen educ1998=educwdma98/popudma1998

gen educw00=educ2000*popu2000
egen educwdma00=sum(educw00), by(dmacode)
rename educ2000 enada2000
gen educ2000=educwdma00/popudma2000

gen educw01=educ2001*popu2001
egen educwdma01=sum(educw01), by(dmacode)
rename educ2001 enada2001
gen educ2001=educwdma01/popudma2001

gen educw03=educ2003*popu2003
egen educwdma03=sum(educw03), by(dmacode)
rename educ2003 enada2003
gen educ2003=educwdma03/popudma2003

gen latinow95=latino1995*popu1997
egen latinowdma95=sum(latinow95), by(dmacode)
rename latino1995 enadaq1995
gen latino1995=latinowdma95/popudma1997

gen latinow97=latino1997*popu1997
egen latinowdma97=sum(latinow97), by(dmacode)
rename latino1997 enadaq1997
gen latino1997=latinowdma97/popudma1997

gen latinow98=latino1998*popu1998
egen latinowdma98=sum(latinow98), by(dmacode)
rename latino1998 enadaq1998
gen latino1998=latinowdma98/popudma1998

gen latinow00=latino2000*popu2000
egen latinowdma00=sum(latinow00), by(dmacode)
rename latino2000 enadaq2000
gen latino2000=latinowdma00/popudma2000

gen latinow01=latino2001*popu2001
egen latinowdma01=sum(latinow01), by(dmacode)
rename latino2001 enadaq2001
gen latino2001=latinowdma01/popudma2001

gen latinow03=latino2003*popu2003
egen latinowdma03=sum(latinow03), by(dmacode)
rename latino2003 enadaq2003
gen latino2003=latinowdma03/popudma2003

gen blackw95=black1995*popu1997
egen blackwdma95=sum(blackw95), by(dmacode)
rename black1995 enadaw1995
gen black1995=blackwdma95/popudma1997

gen blackw97=black1997*popu1997
egen blackwdma97=sum(blackw97), by(dmacode)
rename black1997 enadaw1997
gen black1997=blackwdma97/popudma1997

gen blackw98=black1998*popu1998
egen blackwdma98=sum(blackw98), by(dmacode)
rename black1998 enadaw1998
gen black1998=blackwdma98/popudma1998

gen blackw00=black2000*popu2000
egen blackwdma00=sum(blackw00), by(dmacode)
rename black2000 enadaw2000
gen black2000=blackwdma00/popudma2000

gen blackw01=black2001*popu2001
egen blackwdma01=sum(blackw01), by(dmacode)
rename black2001 enadaw2001
gen black2001=blackwdma01/popudma2001

gen blackw03=black2003*popu2003
egen blackwdma03=sum(blackw03), by(dmacode)
rename black2003 enadaw2003
gen black2003=blackwdma03/popudma2003



*Age Groups*


gen internet3597=internetuse6_34person1997*popu1997
egen internet35dma97=sum(internet3597), by(dmacode)
gen internetuse35_1997=internet35dma97/popudma1997

gen internet3598=internetuse6_34person1998*popu1998
egen internet35dma98=sum(internet3598), by(dmacode)
gen internetuse35_1998=internet35dma98/popudma1998

gen internet3500=internetuse6_34person2000*popu2000
egen internet35dma00=sum(internet3500), by(dmacode)
gen internetuse35_2000=internet35dma00/popudma2000

gen internet3501=internetuse6_34person2001*popu2001
egen internet35dma01=sum(internet3501), by(dmacode)
gen internetuse35_2001=internet35dma01/popudma2001

gen internet3503=internetuse6_34person2003*popu2003
egen internet35dma03=sum(internet3503), by(dmacode)
gen internetuse35_2003=internet35dma03/popudma2003


gen internet35_5497=internetuse35_54person1997*popu1997
egen internet35_54dma97=sum(internet35_5497), by(dmacode)
gen internetuse35_54_1997=internet35_54dma97/popudma1997

gen internet35_5498=internetuse35_54person1998*popu1998
egen internet35_54dma98=sum(internet35_5498), by(dmacode)
gen internetuse35_54_1998=internet35_54dma98/popudma1998

gen internet35_5400=internetuse35_54person2000*popu2000
egen internet35_54dma00=sum(internet35_5400), by(dmacode)
gen internetuse35_54_2000=internet35_54dma00/popudma2000

gen internet35_5401=internetuse35_54person2001*popu2001
egen internet35_54dma01=sum(internet35_5401), by(dmacode)
gen internetuse35_54_2001=internet35_54dma01/popudma2001

gen internet35_5403=internetuse35_54person2003*popu2003
egen internet35_54dma03=sum(internet35_5403), by(dmacode)
gen internetuse35_54_2003=internet35_54dma03/popudma2003


gen internet55plus97=internetuse55plusperson1997*popu1997
egen internet55dmaplus97=sum(internet55plus97), by(dmacode)
gen internetuse55plus1997=internet55dmaplus97/popudma1997

gen internet55plus98=internetuse55plusperson1998*popu1998
egen internet55dmaplus98=sum(internet55plus98), by(dmacode)
gen internetuse55plus1998=internet55dmaplus98/popudma1998

gen internet55plus00=internetuse55plusperson2000*popu2000
egen internet55dmaplus00=sum(internet55plus00), by(dmacode)
gen internetuse55plus2000=internet55dmaplus00/popudma2000

gen internet55plus01=internetuse55plusperson2001*popu2001
egen internet55dmaplus01=sum(internet55plus01), by(dmacode)
gen internetuse55plus2001=internet55dmaplus01/popudma2001

gen internet55plus03=internetuse55plusperson2003*popu2003
egen internet55dmaplus03=sum(internet55plus03), by(dmacode)
gen internetuse55plus2003=internet55dmaplus03/popudma2003




gen educ3595=educ6_34_1995*popu1997
egen educ35dma95=sum(educ3595), by(dmacode)
gen educ35_a1995=educ35dma95/popudma1997

gen educ3597=educ6_34_1997*popu1997
egen educ35dma97=sum(educ3597), by(dmacode)
gen educ35_a1997=educ35dma97/popudma1997

gen educ3598=educ6_34_1998*popu1998
egen educ35dma98=sum(educ3598), by(dmacode)
gen educ35_a1998=educ35dma98/popudma1998

gen educ3500=educ6_34_2000*popu2000
egen educ35dma00=sum(educ3500), by(dmacode)
gen educ35_a2000=educ35dma00/popudma2000

gen educ3501=educ6_34_2001*popu2001
egen educ35dma01=sum(educ3501), by(dmacode)
gen educ35_a2001=educ35dma01/popudma2001

gen educ3503=educ6_34_2003*popu2003
egen educ35dma03=sum(educ3503), by(dmacode)
gen educ35_a2003=educ35dma03/popudma2003

gen educ35_54_95=educ35_54_1995*popu1997
egen educ35_54dma95=sum(educ35_54_95), by(dmacode)
gen educ35_54_a1995=educ35_54dma95/popudma1997

gen educ35_54_97=educ35_54_1997*popu1997
egen educ35_54dma97=sum(educ35_54_97), by(dmacode)
gen educ35_54_a1997=educ35_54dma97/popudma1997

gen educ35_54_98=educ35_54_1998*popu1998
egen educ35_54dma98=sum(educ35_54_98), by(dmacode)
gen educ35_54_a1998=educ35_54dma98/popudma1998

gen educ35_54_00=educ35_54_2000*popu2000
egen educ35_54dma00=sum(educ35_54_00), by(dmacode)
gen educ35_54_a2000=educ35_54dma00/popudma2000

gen educ35_54_01=educ35_54_2001*popu2001
egen educ35_54dma01=sum(educ35_54_01), by(dmacode)
gen educ35_54_a2001=educ35_54dma01/popudma2001

gen educ35_54_03=educ35_54_2003*popu2003
egen educ35_54dma03=sum(educ35_54_03), by(dmacode)
gen educ35_54_a2003=educ35_54dma03/popudma2003

gen educ55plus_95=educ55plus1995*popu1997
egen educ55plusdma95=sum(educ55plus_95), by(dmacode)
gen educ55plus_a1995=educ55plusdma95/popudma1997

gen educ55plus_97=educ55plus1997*popu1997
egen educ55plusdma97=sum(educ55plus_97), by(dmacode)
gen educ55plus_a1997=educ55plusdma97/popudma1997

gen educ55plus_98=educ55plus1998*popu1998
egen educ55plusdma98=sum(educ55plus_98), by(dmacode)
gen educ55plus_a1998=educ55plusdma98/popudma1998

gen educ55plus_00=educ55plus2000*popu2000
egen educ55plusdma00=sum(educ55plus_00), by(dmacode)
gen educ55plus_a2000=educ55plusdma00/popudma2000

gen educ55plus_01=educ55plus2001*popu2001
egen educ55plusdma01=sum(educ55plus_01), by(dmacode)
gen educ55plus_a2001=educ55plusdma01/popudma2001

gen educ55plus_03=educ55plus2003*popu2003
egen educ55plusdma03=sum(educ55plus_03), by(dmacode)
gen educ55plus_a2003=educ55plusdma03/popudma2003

egen population1997dma=sum(popu1997), by(dmacode)
egen population1998dma=sum(popu1998), by(dmacode)
egen population2000dma=sum(popu2000), by(dmacode)
egen population2001dma=sum(popu2001), by(dmacode)
egen population2003dma=sum(popu2003), by(dmacode)


egen numerodeobservation1997=sum(numberofobservations1997), by(dmacode)
egen numerodeobservation1998=sum(numberofobservations1998), by(dmacode)
egen numerodeobservation2000=sum(numberofobservations2000), by(dmacode)
egen numerodeobservation2001=sum(numberofobservations2001), by(dmacode)
egen numerodeobservation2003=sum(numberofobservations2003), by(dmacode)

gen latino3595=latino6_34_1995*popu1997
egen latino35dma95=sum(latino3595), by(dmacode)
gen latino35_a1995=latino35dma95/popudma1997

gen latino3597=latino6_34_1997*popu1997
egen latino35dma97=sum(latino3597), by(dmacode)
gen latino35_a1997=latino35dma97/popudma1997

gen latino3598=latino6_34_1998*popu1998
egen latino35dma98=sum(latino3598), by(dmacode)
gen latino35_a1998=latino35dma98/popudma1998

gen latino3500=latino6_34_2000*popu2000
egen latino35dma00=sum(latino3500), by(dmacode)
gen latino35_a2000=latino35dma00/popudma2000

gen latino3501=latino6_34_2001*popu2001
egen latino35dma01=sum(latino3501), by(dmacode)
gen latino35_a2001=latino35dma01/popudma2001

gen latino3503=latino6_34_2003*popu2003
egen latino35dma03=sum(latino3503), by(dmacode)
gen latino35_a2003=latino35dma03/popudma2003

gen latino35_54_95=latino35_54_1995*popu1997
egen latino35_54dma95=sum(latino35_54_95), by(dmacode)
gen latino35_54_a1995=latino35_54dma95/popudma1997

gen latino35_54_97=latino35_54_1997*popu1997
egen latino35_54dma97=sum(latino35_54_97), by(dmacode)
gen latino35_54_a1997=latino35_54dma97/popudma1997

gen latino35_54_98=latino35_54_1998*popu1998
egen latino35_54dma98=sum(latino35_54_98), by(dmacode)
gen latino35_54_a1998=latino35_54dma98/popudma1998

gen latino35_54_00=latino35_54_2000*popu2000
egen latino35_54dma00=sum(latino35_54_00), by(dmacode)
gen latino35_54_a2000=latino35_54dma00/popudma2000

gen latino35_54_01=latino35_54_2001*popu2001
egen latino35_54dma01=sum(latino35_54_01), by(dmacode)
gen latino35_54_a2001=latino35_54dma01/popudma2001

gen latino35_54_03=latino35_54_2003*popu2003
egen latino35_54dma03=sum(latino35_54_03), by(dmacode)
gen latino35_54_a2003=latino35_54dma03/popudma2003

gen latino55plus_95=latino55plus1995*popu1997
egen latino55plusdma95=sum(latino55plus_95), by(dmacode)
gen latino55plus_a1995=latino55plusdma95/popudma1997

gen latino55plus_97=latino55plus1997*popu1997
egen latino55plusdma97=sum(latino55plus_97), by(dmacode)
gen latino55plus_a1997=latino55plusdma97/popudma1997

gen latino55plus_98=latino55plus1998*popu1998
egen latino55plusdma98=sum(latino55plus_98), by(dmacode)
gen latino55plus_a1998=latino55plusdma98/popudma1998

gen latino55plus_00=latino55plus2000*popu2000
egen latino55plusdma00=sum(latino55plus_00), by(dmacode)
gen latino55plus_a2000=latino55plusdma00/popudma2000

gen latino55plus_01=latino55plus2001*popu2001
egen latino55plusdma01=sum(latino55plus_01), by(dmacode)
gen latino55plus_a2001=latino55plusdma01/popudma2001

gen latino55plus_03=latino55plus2003*popu2003
egen latino55plusdma03=sum(latino55plus_03), by(dmacode)
gen latino55plus_a2003=latino55plusdma03/popudma2003

gen black3595=black6_34_1995*popu1997
egen black35dma95=sum(black3595), by(dmacode)
gen black35_a1995=black35dma95/popudma1997

gen black3597=black6_34_1997*popu1997
egen black35dma97=sum(black3597), by(dmacode)
gen black35_a1997=black35dma97/popudma1997

gen black3598=black6_34_1998*popu1998
egen black35dma98=sum(black3598), by(dmacode)
gen black35_a1998=black35dma98/popudma1998

gen black3500=black6_34_2000*popu2000
egen black35dma00=sum(black3500), by(dmacode)
gen black35_a2000=black35dma00/popudma2000

gen black3501=black6_34_2001*popu2001
egen black35dma01=sum(black3501), by(dmacode)
gen black35_a2001=black35dma01/popudma2001

gen black3503=black6_34_2003*popu2003
egen black35dma03=sum(black3503), by(dmacode)
gen black35_a2003=black35dma03/popudma2003

gen black35_54_95=black35_54_1995*popu1997
egen black35_54dma95=sum(black35_54_95), by(dmacode)
gen black35_54_a1995=black35_54dma95/popudma1997

gen black35_54_97=black35_54_1997*popu1997
egen black35_54dma97=sum(black35_54_97), by(dmacode)
gen black35_54_a1997=black35_54dma97/popudma1997

gen black35_54_98=black35_54_1998*popu1998
egen black35_54dma98=sum(black35_54_98), by(dmacode)
gen black35_54_a1998=black35_54dma98/popudma1998

gen black35_54_00=black35_54_2000*popu2000
egen black35_54dma00=sum(black35_54_00), by(dmacode)
gen black35_54_a2000=black35_54dma00/popudma2000

gen black35_54_01=black35_54_2001*popu2001
egen black35_54dma01=sum(black35_54_01), by(dmacode)
gen black35_54_a2001=black35_54dma01/popudma2001

gen black35_54_03=black35_54_2003*popu2003
egen black35_54dma03=sum(black35_54_03), by(dmacode)
gen black35_54_a2003=black35_54dma03/popudma2003

gen black55plus_95=black55plus1995*popu1997
egen black55plusdma95=sum(black55plus_95), by(dmacode)
gen black55plus_a1995=black55plusdma95/popudma1997

gen black55plus_97=black55plus1997*popu1997
egen black55plusdma97=sum(black55plus_97), by(dmacode)
gen black55plus_a1997=black55plusdma97/popudma1997

gen black55plus_98=black55plus1998*popu1998
egen black55plusdma98=sum(black55plus_98), by(dmacode)
gen black55plus_a1998=black55plusdma98/popudma1998

gen black55plus_00=black55plus2000*popu2000
egen black55plusdma00=sum(black55plus_00), by(dmacode)
gen black55plus_a2000=black55plusdma00/popudma2000

gen black55plus_01=black55plus2001*popu2001
egen black55plusdma01=sum(black55plus_01), by(dmacode)
gen black55plus_a2001=black55plusdma01/popudma2001

gen black55plus_03=black55plus2003*popu2003
egen black55plusdma03=sum(black55plus_03), by(dmacode)
gen black55plus_a2003=black55plusdma03/popudma2003


collapse  black1995 black1997 black1998 black2000 black2001 black2003 latino1995 latino1997 latino1998 latino2000 latino2001 latino2003 latino35_54_a1995 latino35_54_a1997 latino35_54_a1998 latino35_54_a2000 latino35_54_a2001 latino35_54_a2003 latino55plus_a1995 latino55plus_a1997 latino55plus_a1998 latino55plus_a2000 latino55plus_a2001 latino55plus_a2003 latino35_a1995 latino35_a1997 latino35_a1998 latino35_a2000 latino35_a2001 latino35_a2003 black35_54_a1995 black35_54_a1997 black35_54_a1998 black35_54_a2000 black35_54_a2001 black35_54_a2003 black55plus_a1995 black55plus_a1997 black55plus_a1998 black55plus_a2000 black55plus_a2001 black55plus_a2003 black35_a1995 black35_a1997 black35_a1998 black35_a2000 black35_a2001 black35_a2003 population1997dma population1998dma population2000dma population2001dma population2003dma numerodeobservation1997 numerodeobservation1998 numerodeobservation2000 numerodeobservation2001 numberofobservations2003 educ35_54_a1995 educ35_54_a1997 educ35_54_a1998 educ35_54_a2000 educ35_54_a2001 educ35_54_a2003 educ55plus_a1995 educ55plus_a1997 educ55plus_a1998 educ55plus_a2000 educ55plus_a2001 educ55plus_a2003 educ35_a1995 educ35_a1997 educ35_a1998 educ35_a2000 educ35_a2001 educ35_a2003 internetuse35_54_1997 internetuse35_54_1998 internetuse35_54_2000 internetuse35_54_2001 internetuse35_54_2003 internetuse35_1997 internetuse35_1998 internetuse35_2000 internetuse35_2001 internetuse35_2003 internetuse55plus1997 internetuse55plus1998 internetuse55plus2000 internetuse55plus2001 internetuse55plus2003 educ1995 educ1997 educ1998 educ2000 educ2001 educ2003 income1995 income1997 income1998  income2000 income2001  income2003 internetuse1997 internetuse1998  internetuse2000 internetuse2001  internetuse2003, by (dmacode) 

joinby dmacode using "C:\Documents and Settings\axz051000\My Documents\guale2009\stan\cps\restatonline\ratinganduniverse19902006final", unmatched(both)
tab _merge
drop if _merge~=3
drop _merge

joinby dmacode using "C:\Documents and Settings\axz051000\My Documents\guale2009\stan\cps\restatonline\medianincomepercapita", unmatched(both)

tab _merge
drop _merge

reshape long  medianincomepercapita medianincomepercapita634_ medianincomepercapita3554_ medianincomepercapita55plus_ income ratingdma_ a educ35_54_a educ55plus_a educ35_a latino black latino35_54_a latino55plus_a latino35_a black35_54_a black55plus_a black35_a  ratingdma55plus ratingdma6_34_ ratingdma35_54_  educ internetuse35_ internetuse55plus internetuse35_54_  internetuse totalhh_ spanish_ black_, i(dmacode) j(year)
tsset  dmacode year
destring, replace

gen totalhh=totalhh_*10
gen blackpercentage=black_/totalhh 
gen spanishpercentage=spanish_/totalhh

keep if year==1997 | year==1998 | year==2000 | year==2001 | year==2003 | year==1995

replace internetuse35_=0 if year==1995
replace internetuse35_54_=0 if year==1995
replace internetuse55plus=0 if year==1995
replace internetuse=0 if year==1995

tab year, gen(y)

gen ratingdmahora=((ratingdma_/100)*18)*60
gen ratingdma6_34_hora=((ratingdma6_34_/100)*18)*60
gen ratingdma35_54_hora=((ratingdma35_54_ /100)*18)*60
gen ratingdma55plus_hora=((ratingdma55plus /100)*18)*60

drop if dmacode==646
drop if dmacode==620
drop if dmacode==747
drop if dmacode==630
*ANNISTON,TUSCALOOSA,BIRMINGHAM,JUNEAU*

*coverage*
gen diff=(population1998dma-pobdma_1998)/pobdma_1998
sum diff

*Note that the sum of the population in the MSA (from the census) in dmacodes 522, 536, 551, 749, 800, and 855 is larger than the population of the DMA (from Nielsen)*
*This is not caused by the split msas. These are MSAs that are in more than one DMA* 

table year, content(mean internetuse median internetuse sd internetuse p5 internetuse p95 internetuse)
table year, content(mean internetuse35_ median internetuse35_ sd internetuse35_ p5 internetuse35_ p95 internetuse35_)
table year, content(mean internetuse35_54_  median internetuse35_54_  sd internetuse35_54_  p5 internetuse35_54_  p95 internetuse35_54_ )
table year, content(mean internetuse55plus  median internetuse55plus sd internetuse55plus p5 internetuse55plus p95 internetuse55plus)

table year , content(mean ratingdmahora median ratingdmahora sd ratingdmahora p5 ratingdmahora p95 ratingdmahora)
table year , content(mean ratingdma6_34_hora median ratingdma6_34_hora sd ratingdma6_34_hora p5 ratingdma6_34_hora p95 ratingdma6_34_hora)
table year , content(mean ratingdma35_54_hora  median ratingdma35_54_hora  sd ratingdma35_54_hora  p5 ratingdma35_54_hora p95 ratingdma35_54_hora )
table year , content(mean ratingdma55plus_hora  median ratingdma55plus_hora sd ratingdma55plus_hora p5 ratingdma55plus_hora p95 ratingdma55plus_hora)

table year , content(mean income  median income sd income p5 income p95 income)
table year , content(mean educ  median educ sd educ p5 educ p95 educ)
table year , content(mean black  median black sd black p5 black p95 black)
table year , content(mean latino  median latino sd latino p5 latino p95 latino)

egen pobtotal2003=sum(pobdma_2003) if year==2003

gen internet35_aux=internetuse35_*pobdma_2003 if year==2003
egen internet35_auxx=sum( internet35_aux) if year==2003
gen internet35= internet35_auxx/ pobtotal2003
sum internet35

gen internet3554_aux=internetuse35_54_*pobdma_2003 if year==2003
egen internet3554_auxx=sum( internet3554_aux) if year==2003
gen internet3554= internet3554_auxx/ pobtotal2003
sum internet3554

gen internet55plus_aux=internetuse55plus*pobdma_2003 if year==2003
egen internet55plus_auxx=sum( internet55plus_aux) if year==2003
gen internet55plus= internet55plus_auxx/ pobtotal2003
sum internet55plus


*Table 4*

reg  ratingdmahora  internetuse black latino  medianincomepercapita educ if   year==1997 &  diff>-0.3 & diff<0.3 [aw= numerodeobservation1997], robust
outreg internetuse  black latino  medianincomepercapita educ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(I) replace

reg  ratingdmahora  internetuse black latino  medianincomepercapita educ if   year==1998 &  diff>-0.3 & diff<0.3 [aw= numerodeobservation1998], robust
outreg internetuse  black latino  medianincomepercapita educ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(II) append

reg  ratingdmahora  internetuse black latino  medianincomepercapita educ if   year==2000 &  diff>-0.3 & diff<0.3 [aw= numerodeobservation2000], robust
outreg internetuse  black latino  medianincomepercapita educ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(III) append

reg  ratingdmahora  internetuse black latino  medianincomepercapita educ if   year==2001 &  diff>-0.3 & diff<0.3 [aw= numerodeobservation2001], robust
outreg internetuse  black latino   medianincomepercapita educ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(IV) append

reg  ratingdmahora  internetuse black latino  medianincomepercapita educ if   year==2003 &  diff>-0.3 & diff<0.3 [aw=  numberofobservations2003], robust
outreg internetuse  black latino  medianincomepercapita educ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(V) append


*Table 5*
*all ages*
areg   ratingdmahora y1-y6    internetuse black latino educ medianincomepercapita if diff>-0.3 & diff<0.3 [aw= numerodeobservation2000] , absorb(dmacode) robust
outreg internetuse  black latino educ medianincomepercapita using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(I) replace
areg   ratingdmahora y1-y6    internetuse black latino educ medianincomepercapita [aw= numerodeobservation2000] , absorb(dmacode) robust
outreg internetuse  black latino educ medianincomepercapita using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(II) append

*footnote 30*
areg   ratingdmahora y1-y6    internetuse blackpercentage spanishpercentage educ medianincomepercapita if diff>-0.3 & diff<0.3 [aw= numerodeobservation2000] , absorb(dmacode) robust
areg   ratingdmahora y1-y6    internetuse blackpercentage spanishpercentage educ medianincomepercapita [aw= numerodeobservation2000] , absorb(dmacode) robust

*6-34*
areg   ratingdma6_34_hora y1-y6    internetuse35_ black35_a latino35_a educ35_a medianincomepercapita634_ if diff>-0.3 & diff<0.3 [aw= numerodeobservation2000] , absorb(dmacode) robust
outreg internetuse35_  black35_a latino35_a educ35_a medianincomepercapita634_ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(I) append
areg   ratingdma6_34_hora y1-y6    internetuse35_ black35_a latino35_a educ35_a medianincomepercapita634_ [aw= numerodeobservation2000] , absorb(dmacode) robust
outreg internetuse35_  black35_a latino35_a educ35_a medianincomepercapita634_ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(II) append
 
*35-54*
areg   ratingdma35_54_hora  y1-y6    internetuse35_54_ black35_54_a  latino35_54_a educ35_54_a medianincomepercapita3554_ if diff>-0.3 & diff<0.3 [aw= numerodeobservation2000] , absorb(dmacode) robust
outreg internetuse35_54_  black35_54_a  latino35_54_a educ35_54_a medianincomepercapita3554_ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(I) append
areg   ratingdma35_54_hora  y1-y6   internetuse35_54_ black35_54_a  latino35_54_a educ35_54_a medianincomepercapita3554_ [aw= numerodeobservation2000] , absorb(dmacode) robust
outreg internetuse35_54_  black35_54_a  latino35_54_a educ35_54_a medianincomepercapita3554_ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(II) append

*55 plus*
areg   ratingdma55plus_hora  y1-y6   internetuse55plus black55plus_a latino55plus_a educ55plus_a medianincomepercapita55plus_ if diff>-0.3 & diff<0.3 [aw= numerodeobservation2000] , absorb(dmacode) robust
outreg internetuse55plus  black55plus_a latino55plus_a educ55plus_a medianincomepercapita55plus_ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(I) append
areg   ratingdma55plus_hora  y1-y6    internetuse55plus black55plus_a latino55plus_a educ55plus_a medianincomepercapita55plus_ [aw= numerodeobservation2000] , absorb(dmacode) robust
outreg internetuse55plus  black55plus_a latino55plus_a educ55plus_a medianincomepercapita55plus_ using tableT2A, se nolabel coefastr bdec(4) rdec(4) sigsymb(***,**,*) 10pct  ctitle(II) append




